<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en" class="no-js">

<head>

<meta charset="utf-8">
<title>校友注册页面</title>
	<base href="<%=basePath%>">
<meta name="copyright" content="Copyright   www.xmoban.cn">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
	<link href="less/Black.ico" rel="shortcut icon" />
<link rel="stylesheet" href="resourse/plugins/login/css/reset.css">
<link rel="stylesheet" href="resourse/plugins/login/css/supersized.css">
<link rel="stylesheet" href="resourse/plugins/login/css/style.css">
	<link href="resourse/plugins/toast/jquery.toast.css" rel="stylesheet">

</head>

<body>
<input type="hidden" name="path"     id="path"   value="<%=request.getContextPath()%>" />
	<div class="page-container">
		<h1>会员注册</h1>
		<form  id="from">
			<input type="text" id="username" class="username" placeholder="账号(用学号)" autocomplete="off" required="true">
			<input type="text" id="realname" class="username" placeholder="姓名" autocomplete="off" required="true">
			<input type="password" id="password" class="password" placeholder="密码" autocomplete="off" required="true">
			<input type="text"  id="phone" placeholder="手机号" required="true">
			<input type="email" id="email"  placeholder="邮箱" required="true">
			<input type="date" id="birthday"  placeholder="生日" required="true">
			<input type="date" id="intime"  placeholder="入学时间" required="true">

			<button id="btn_submit" type="submit">提交</button>

		</form>

	</div>


	<!-- Javascript -->
	<script src='js/jquery-2.0.3.js'></script>
	<script src="resourse/plugins/login/js/supersized.3.2.7.min.js"></script>
	<script src="resourse/plugins/login/js/supersized-init.js"></script>
	<script type="text/javascript" src="js/jquery.md5.js"></script>
	<script src="resourse/plugins/toast/jquery.toast.js"></script>
	<script>
	$("#from").on('submit',function(){
	var username=$("#username").val();
	var realname=$("#realname").val();
	var password=$("#password").val();
	var phone=$("#phone").val();
	var email=$("#email").val();
	var birthday=$("#birthday").val();
	var intime=$("#intime").val();
		if(!checkValidate(username)){
			toastAlert("error","错误","用户账号6~12字母数字!");
		return  false;
		}
		else if(!checkRealName(realname))
		{toastAlert("error","错误","最多10位字符");
			return  false;
		}
		else if(!checkpwd(password)){
			toastAlert("error","错误","密码6~12位");
			return  false;
		}
		else if(!checkPhone(phone)){
			toastAlert("error","错误","请输入正确的手机号!");
			return  false;
		}
		else if(!checkMail(email)){
			toastAlert("error","错误","输入正确的邮箱!");
			return  false;
		}

	$.post(
	$("#path").val()+"/addUser",
	{
		id:0,
	username : username,
	password : $.md5(password) ,
	realname : realname ,
	phone : phone ,
	email : email ,
		birthdayTo : birthday ,
	intimeTo : intime ,
	usertype : 3 ,
		majorid : 1 ,
	//32x
	},
	function(data){
	data=$.parseJSON(data);
	if(data.status=="false"){
	toastAlert("error","错误",data.msg);
	}
	else {
		toastAlert("success",data.msg,"5s后自动跳转登入页");
		setTimeout(function(){
			window.location.href=$("#path").val()+'/login.jsp';
		},5000);

	}

	}
	)

	return false;

	});
	//  绑定  键盘 回车键==登入键
	$(document).keydown(function(event){
	if(event.keyCode == 13){  $("#btn_submit").click();  }
	});
	// 提示框事件
	function toastAlert(icon,heading,text){
	$.toast({
	heading: heading,
	text: text,
	stack: false,
	position: 'mid-center',
	showHideTransition: 'fade',
	icon: icon   // icon:error warning  success info
	})
	}





	//  只能  数字字母
	function checkValidate(str){
		var reg = /^[A-Za-z0-9]+$/;
		if(reg.test(str)&&str.length<11&&str.length>5){
			return true
		}
		else
			return false;
	}

	function checkRealName(str){
		if(str.length<11){
			return true;
		}
		else
			return false;
	}

	function checkpwd(value){
		if (value!=null&&value!=""&&value.length>5&&value.length<13)
			return true;
		else
			return false;
	}
	function checkPhone(o){
		var reg=/^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$/;
		if(reg.test(o)){
			return true
		}
		else
			return false;
	}

	function checkMail(o){
		var reg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(reg.test(o)){
			return true;
		}
		else
			return false;
	}
	</script>
</body>

</html>

